package com.compass.doctor.ui.prescription

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.compass.doctor.base.BaseVBActivity
import com.compass.doctor.databinding.ActivityPrescriptionExamineBinding
import com.compass.doctor.ui.prescription.fragment.HistoryRxFragment
import com.compass.doctor.ui.prescription.fragment.RxToBeExamineFragment
import com.compass.framework.adapter.ViewPage2FragmentAdapter

/**
 * Description： 处方审核
 * Date:2024/2/21 14:22
 */
class PrescriptionExamineActivity : BaseVBActivity<ActivityPrescriptionExamineBinding>(){


    companion object {
        fun start(context: Context) {
            val intent = Intent(context, PrescriptionExamineActivity::class.java)
            context.startActivity(intent)
        }
    }

    private lateinit var viewPageAdapter: ViewPage2FragmentAdapter
    private var fragments: ArrayList<Fragment> = ArrayList()

    private lateinit var rxToBeExamineFragment: RxToBeExamineFragment
    private lateinit var historyRxFragment: HistoryRxFragment


    override fun initView(savedInstanceState: Bundle?) {
        initFragment()
        mBinding.dslTab.tabIndicator.indicatorWidth = -2
        mBinding.dslTab.tabIndicator.indicatorEnableFlow = true
        mBinding.dslTab.configTabLayoutConfig {
            onSelectIndexChange = { _, selectIndexList, _, _ ->
                val toIndex = selectIndexList.first()
                mBinding.viewpager2.setCurrentItem(toIndex, false)
            }
        }
        viewPageAdapter = ViewPage2FragmentAdapter(supportFragmentManager, lifecycle, fragments)
        mBinding.viewpager2.adapter = viewPageAdapter
        mBinding.viewpager2.isUserInputEnabled = false//禁止viewPage滑动
        mBinding.viewpager2.setCurrentItem(0, false)

    }

    private fun initFragment() {
        rxToBeExamineFragment = RxToBeExamineFragment()
        fragments.add(rxToBeExamineFragment)

        historyRxFragment = HistoryRxFragment()
        fragments.add(historyRxFragment)

    }
}